use "dataset_other_texas_cities", clear

replace city = subinstr(city, ", texas", "", 1)

local i = 1
levelsof city, local(cityes)
foreach city of local cityes {

	local mygraphs

	local j = word("`c(alpha)'", `i')
	
	preserve

		keep if city == "`city'"

		drop if mi(pctyes) | mi(pctnhblack)
		gen pctyes_post = pctyes if year >= 2020

		levelsof year, local(levels)
		foreach year of local levels {
		
			su pctnhblack if year == `year'
			gen x = (pctnhblack - r(min)) / (r(max) - r(min))
			reg pctyes x [aw=totalvotes] if year == `year', robust
			local b = string(_b[x], "%20.02fc")
			local se = string(_se[x], "%20.02fc")
			drop x
			
			#delimit;
			
			gr tw
				(sc pctyes pctnhblack [aw=totalvotes] 
					if year == `year', msym(Oh)
					msize(tiny))
				(sc pctyes_post pctnhblack [aw=totalvotes] 
					if year == `year', msym(O)
					msize(tiny))
				(lpoly pctyes pctnhblack [aw=totalvotes]
					if year == `year', lcol(black)
					lwid(thick))
				,
					legend(off)	
					plotregion(style(none))
					ylab(, angle(horiz))
					xtitle("")
					ytitle("")
					title(`year')
					name(g`year', replace)
					subtitle({&beta} = `b' (`se'),
						size(small))
					nodraw
					;
			
			#delimit cr
		
			local mygraphs `mygraphs' g`year'
			
		}

		gr combine `mygraphs', cols(7) title("`city'") ///
			b1title("Share Black") l1title("Share Yes Vote") ///
			imargin(zero) ycommon xsize(2) ysize(1)

		gr export "_output/figure A27 `j'.pdf", replace
		
		gr close
		
	restore
	
	
	
	local i = `i' + 1

}
